"""
测试财务添加应收款点击取消
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

#打开浏览器
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(30)
#打开crm
driver.get("http://192.168.1.25/crm")
sleep(1)
#准备数据
username = "admin"
password = "123456"
ysk_name = "keke"
skje = "666"
#定位器
username_locator = (By.NAME,'name')
password_locator = (By.NAME,'password')
login_btn_locator = (By.NAME,'submit')
cw_locator = (By.LINK_TEXT,'财务')
xj_ysk_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(1) > div.pull-right > a:nth-child(1)')
ysk_name_locator = (By.NAME,'name')
kh_name_locator = (By.NAME,'customer')
xzkh_locator =(By.CSS_SELECTOR,'input[value="3"]')
kh_btn_locator =(By.CSS_SELECTOR,'body > div:nth-child(8) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span')
skje_locator = (By.NAME,'price')
ysk_qx_btn_locator =(By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(3)')


#登录输入用户名和密码
driver.find_element(*username_locator).send_keys(username)
driver.find_element(*password_locator).send_keys(password)
sleep(1)
#点击登录
driver.find_element(*login_btn_locator).click()
sleep(1)
#点击财务
driver.find_element(*cw_locator).click()
sleep(1)
#点击新建
driver.find_element(*xj_ysk_locator).click()
sleep(1)
#输入应收款名
driver.find_element(*ysk_name_locator).send_keys(ysk_name)
sleep(1)
#选择客户
driver.find_element(*kh_name_locator).click()
sleep(1)
driver.find_element(*xzkh_locator).click()
sleep(1)
#点击客户确定按钮
driver.find_element(*kh_btn_locator).click()
sleep(1)
#输入收款金额
driver.find_element(*skje_locator).send_keys(skje)
sleep(2)
#点击取消
driver.find_element(*ysk_qx_btn_locator).click()
sleep(2)

sleep(2)
driver.quit()